import java.io.*;
import java.util.*;

public class Main {
	String input;
	StringTokenizer st;
	BufferedReader br;
	StringBuilder sb;
	
	public Main() {
		br = new BufferedReader(new InputStreamReader(System.in));
		sb = new StringBuilder();
	}
	
	public static void main(String[] args) throws IOException {
		Main main = new Main();
		main.beginProcess();
	}

	void beginProcess() throws IOException {
		long k,
			n;
		while((input = br.readLine()) != null) {
			st = new StringTokenizer(input);
			k = Integer.parseInt(st.nextToken());
			
			input = br.readLine();
			st = new StringTokenizer(input);
			while(k-- > 0) {
				n = Integer.parseInt(st.nextToken());
				sb.append(f91(n) + "\n");
			}
		}
		System.out.print(sb);
	}
	
	long f91(long n) {
		if(n <= 100) return f91(f91(n + 11));
		else if(n >= 101) return n - 10;
		return 0;
	}
	
}